plugins["Rank"] = "kontrol_rank"

if SERVER then
	function Rank(pl, cmd, args)
		if !pl:KOwner() then return end
		
		local target = player.GetByUniqueID(args[1])
		local rank = args[2]
		
		if SQL_ACCESS then
		
		else
			if target then
				target:SetRank(rank)
			end
		end
	end
	concommand.Add("sv_kontrol_rank", Rank)
end

if CLIENT then
	function RankMenu(pl, cmd, args)
		local target = args[1]
		local rank
	
		local menu = vgui.Create("KFrame2")
		menu:SetSize(300, 102)
		menu:SetPos(ScrW() / 2 - 150, ScrH() / 2 - 51)
		menu:SetTitle("Set Rank")
		menu:SetDraggable(true)
		menu:ShowCloseButton(true)
		menu:SetSizable(false)
		
		local rankBox = vgui.Create("DMultiChoice", menu)
		rankBox:SetPos(10, 37)
		rankBox:SetSize(280, 20)
		rankBox:AddChoice("admin")
		rankBox:AddChoice("moderator")
		rankBox:AddChoice("player")
		rankBox.OnSelect = function(panel, index, value)
			rank = value
		end
		
		local accept = vgui.Create("KButton", menu)
		accept:SetSize(100, 20)
		accept:SetPos(100, 67)
		accept:SetText("Accept")
		accept.DoClick = function()
			RunConsoleCommand("sv_kontrol_rank", target, rank)
			menu:Close()
		end
		
		menu:MakePopup()
	end
	concommand.Add("kontrol_rank", RankMenu)
end